package com.polymer.app.rabbitmq;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.polymer.app.entity.BussinessDO;

@RestController
public class TestCreateMqMessage {
    
    @Autowired
    private RabbitTemplate template;

    @GetMapping(value = "mq/create")
    public String createMassage() {
        BussinessDO bsDO=new BussinessDO();
        bsDO.setDescr("hello");
        bsDO.setParamType(System.currentTimeMillis()+"");
        bsDO.setParamValue("hei");
        bsDO.setRemark("hi");
        Object jsonString = JSONObject.toJSON(bsDO);
        template.convertAndSend(AmqpConfig.EXCHANGE, AmqpConfig.ROUTINGKEY,jsonString);
        return "ok";
    }
}
